/**
 *
 */
package com.ce.pms.house.service.impl;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import com.ce.pms.base.service.impl.PmsBaseServiceImpl;
import com.ce.pms.charge.dao.IAccountDao;
import com.ce.pms.charge.dao.IBankAccountDao;
import com.ce.pms.charge.dao.IFeeBankDao;
import com.ce.pms.charge.model.AccountDomain;
import com.ce.pms.charge.model.BankAccountDomain;
import com.ce.pms.charge.model.BankDomain;
import com.ce.pms.charge.model.PeriodDomain;
import com.ce.pms.charge.service.IAccountService;
import com.ce.pms.charge.service.IBankAccountService;
import com.ce.pms.charge.service.IPeriodService;
import com.ce.pms.charge.service.ITransactionService;
import com.ce.pms.charge.vo.BankAccountVO;
import com.ce.pms.common.model.SysInfo;
import com.ce.pms.common.model.SysrefcodeDO;
import com.ce.pms.customer.dao.IClientRHouseDao;
import com.ce.pms.customer.dao.IProRightDao;
import com.ce.pms.customer.model.ClientDO;
import com.ce.pms.customer.model.ClientRHouseDO;
import com.ce.pms.customer.model.ProRightDO;
import com.ce.pms.exception.BusinessException;
import com.ce.pms.house.dao.ICoalitionHouseDao;
import com.ce.pms.house.dao.IHouseDao;
import com.ce.pms.house.model.CoalitionHouseDomain;
import com.ce.pms.house.model.HouseDomain;
import com.ce.pms.house.service.ICoalitionHouseService;
import com.ce.pms.house.service.IHouseService;
import com.ce.pms.house.service.IProRightChangeService;
import com.ce.pms.house.vo.CoalitionHouseVO;
import com.ce.pms.house.vo.HouseVO;
import com.ce.pms.occupation.dao.IIdentityValidateDao;
import com.ce.util.BeanUtil;
import com.ce.util.BlankUtil;

/**
 * @function
 * @author Adama Yue
 * @CreateDate:2008-7-3
 */
public class CoalitionHouseServiceImpl extends PmsBaseServiceImpl implements
		ICoalitionHouseService {
	private ICoalitionHouseDao coalitionHouseDao;
	private IHouseDao houseDao;
	private IClientRHouseDao clientRHouseDao;
	private IBankAccountDao bankAccountDao;
	private IProRightDao proRightDao;
	private IAccountService accountService;
	private IAccountDao accountDao;
	private IBankAccountService bankAccountService;
	private IFeeBankDao feeBankDao;
	private IPeriodService periodService;
	private IHouseService houseService;
	private ITransactionService transactionService;
	private IProRightChangeService proRightChangeService;
	private IIdentityValidateDao identityValidateDao;

	public void setIdentityValidateDao(IIdentityValidateDao identityValidateDao) {
		this.identityValidateDao = identityValidateDao;
	}


	public void setProRightChangeService(
			IProRightChangeService proRightChangeService) {
		this.proRightChangeService = proRightChangeService;
	}


	public void setTransactionService(ITransactionService transactionService) {
		this.transactionService = transactionService;
	}


	public void setPeriodService(IPeriodService periodService) {
		this.periodService = periodService;
	}


	public void setHouseService(IHouseService houseService) {
		this.houseService = houseService;
	}



	/***
	 * 功能描述:  新增管理房<br>
	 * @param CoalitionHouseVO vo
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2008-9-5  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public void addCoalitionHouse(CoalitionHouseVO vo) {

		SysInfo info = createInfo(vo.getOperator());

		//新增管理房记录
		CoalitionHouseDomain coalition = null;
		checkCoalitionHouseNumber(vo.getCoalitionHouseNumber(), vo.getCoalitionId());
		checkValidity(vo.getChoiceHouseStr());
		Set<HouseDomain> houses = getHouses(vo.getChoiceHouseStr());
		//若已存在房屋关系则修改,否则新增
		if (!BlankUtil.isBlank(coalition=coalitionHouseDao.findOld(houses))) {
			coalition.setValidity(SysrefcodeDO.CONSTANTS_DIGITAL_ONE);
			coalition.setHouseNumber(vo.getCoalitionHouseNumber());
			coalition.setCoalitionType(this.sysrefcodeDao.findById(vo.getCoalitionType()));
			coalitionHouseDao.updateObject(coalition);
		}else{
			coalition= new CoalitionHouseDomain(
					vo.getCoalitionHouseNumber(),
					houses,
					this.sysrefcodeDao.findById(vo.getCoalitionType()),
					info);
			coalitionHouseDao.saveObject(coalition);
		}
		checkValidity(coalition);


		//增加产权
		ProRightDO proRight = new ProRightDO(coalition,info);
		proRight.setChargeSelect(vo.getCoalitionStrategy());
		proRightDao.saveProRight(proRight);

		//增加业主管理房关系
		Set<ClientRHouseDO> set = excludeExistClientRHouseDO(clientRHouseDao.getByHousesAndClientType(houses, sysrefcodeDao.getSysrefCodesByCode(SysrefcodeDO.CS_CLIENT_CLIENT_TYPE_CODE, SysrefcodeDO.CLIENT_TYPE_OWNER)));
		for(ClientRHouseDO crh:set) {
			ClientDO owner = crh.getClient();
			ClientRHouseDO nCrh = new ClientRHouseDO(owner,null,coalition,SysrefcodeDO.CONSTANTS_DIGITAL_ONE);
			nCrh.setProRight(proRight);
			clientRHouseDao.saveOrUpdateObject(nCrh);
		}

		//增加银行帐户
		if(!BlankUtil.isBlank(vo.getBankAccount()) && checkBankAccount(vo.getBankAccount())){
			BankAccountDomain bankAccount = new BankAccountDomain();
			BankDomain bank = feeBankDao.findById(vo.getBankAccount().getBankId());
			BeanUtil.convertVoAsDo(vo.getBankAccount(),bankAccount);
			bankAccount.setKeyword(null);
			bankAccount.setSysInfo(info);
			bankAccount.setHouse(coalition);
			bankAccount.setBank(bank);
			bankAccount.setIsActive(SysrefcodeDO.CONSTANTS_DIGITAL_ONE);
			bankAccount.setProRight(proRight);
			bankAccountDao.saveObject(bankAccount);
			for (HouseDomain h: houses) {
				//将产权房银行账户设为不可用
				BankAccountDomain localBankAccount = bankAccountService.currentBankAccount(h,true);
				if(!BlankUtil.isBlank(localBankAccount))
					bankAccountService.disableBankAccount(localBankAccount);
			}
		}

		//合并记帐
		if(SysrefcodeDO.CONSTANTS_DIGITAL_ZERO.equals(vo.getCoalitionStrategy())){
			//增加管理房帐户
		    accountService.addAccount(coalition,proRight,info);
			for (HouseDomain h: houses) {
				AccountDomain account =  accountService.currentAccount(h);
				if(!BlankUtil.isBlank(account)){
					if(transactionService.checkAccountHasHangsTransaction(account.getAccountId())){
						throw new BusinessException("house:house_coalitionhouse_hashangs_add_exception",BusinessException.ERROR);
					}
					accountService.disableAccount(account);
				}
				ProRightDO proRightFlat = proRightDao.getEffectiveProRightByHouse(h);
				//将产权房记费策略设为合并记帐
				proRightFlat.setChargeSelect(SysrefcodeDO.CONSTANTS_DIGITAL_ZERO);
			}
		}

	}

	/* (non-Javadoc)
	 * @see com.ce.pms.house.service.ICoalitionHouseService#deleteCoalitionHouse(java.lang.Long, java.util.List)
	 */
	public void deleteCoalitionHouse(Long CoalitionHouseId, Long operator) {
		CoalitionHouseDomain coalition = coalitionHouseDao.findById(CoalitionHouseId);

		//入伙资料收发验证
		List<Long> list = new ArrayList<Long>();
		for(HouseDomain h : coalition.getHouses()){
			list.add(h.getKeyword());
		}
		boolean result = identityValidateDao.isAllowReleaseRealAndVirtual(CoalitionHouseId, list);
		if(result == false){
			throw new BusinessException("house:occupation_not_finish");
		}
		//查询管理房产权
		ProRightDO proRight = proRightDao.getEffectiveProRightByHouse(coalition);


		//修改记帐策略(与管理房的记帐策略看齐),激活产权房账户及银行账户
		for (HouseDomain h: coalition.getHouses()) {
			//只有当解除时记帐策略为合并才执行,分开时没必要再激活
			if(SysrefcodeDO.CONSTANTS_DIGITAL_ZERO.equals(proRight.getChargeSelect()))
			{
				ProRightDO right = this.proRightDao.getEffectiveProRightByHouse(h);
				AccountDomain acc =  accountDao.getAccountBy(right.getProRightId(), h.getKeyword(), false);
				accountService.activeAccount(acc);
				BankAccountDomain localBankAccount = bankAccountService.currentBankAccount(h,false);
				if(!BlankUtil.isBlank(localBankAccount))
					bankAccountService.activationBankAccount(localBankAccount);
				ProRightDO proRightFlat = proRightDao.getEffectiveProRightByHouse(h);
				proRightFlat.setChargeSelect(SysrefcodeDO.CONSTANTS_DIGITAL_ONE);
			}
		}

		//修改客户房屋关系中状态
		for(ClientRHouseDO crh:clientRHouseDao.getClientRHouseListByHouseIdAndClientType(CoalitionHouseId, sysrefcodeDao.getSysrefCodesByCode(SysrefcodeDO.CS_CLIENT_CLIENT_TYPE_CODE, SysrefcodeDO.CLIENT_TYPE_OWNER).getId())) {
			crh.setValidity(SysrefcodeDO.CONSTANTS_DIGITAL_ZERO);//管理房的客户房屋关系设为无效
			clientRHouseDao.saveOrUpdateObject(crh);
		}

		//修改管理房银行账号
		BankAccountDomain bankAccount = bankAccountService.currentBankAccount(coalition,true);
		if(!BlankUtil.isBlank(bankAccount))
			bankAccountService.disableBankAccount(bankAccount);

		//修改管理房账户状态
		AccountDomain account = accountService.currentAccount(coalition);
		if(!BlankUtil.isBlank(account)){
			if(transactionService.checkAccountHasHangsTransaction(account.getAccountId())){
				throw new BusinessException("house:house_coalitionhouse_hashangs_delete_exception",BusinessException.ERROR);
			}
			accountService.disableAccount(account);
		}
		//修改管理房的产权状态为无效
		proRight.setValidity(SysrefcodeDO.CONSTANTS_DIGITAL_ZERO);
		//记帐策略设为分开记帐
		proRight.setChargeSelect(SysrefcodeDO.CONSTANTS_DIGITAL_ONE);
		//将管理房设为无效
		coalition.setValidity(SysrefcodeDO.CONSTANTS_DIGITAL_ZERO);
		//解除合并时间
		modifyInfo(coalition.getSysInfo(),operator);

	}

	/* (non-Javadoc)
	 * @see com.ce.pms.house.service.ICoalitionHouseService#editCoalitionHouse(com.ce.pms.house.vo.CoalitionHouseVO)
	 */
	public void editCoalitionHouse(CoalitionHouseVO vo) {
		CoalitionHouseDomain coalition = coalitionHouseDao.findById(vo.getCoalitionId());
		coalition.setCoalitionType(this.sysrefcodeDao.findById(vo.getCoalitionType()));
		coalition.setHouseNumber(vo.getCoalitionHouseNumber());
		modifyInfo(coalition.getSysInfo(),vo.getOperator());
		checkValidity(coalition);
		checkCoalitionHouseNumber(vo.getCoalitionHouseNumber(), vo.getCoalitionId());
		SysInfo info = createInfo(vo.getOperator());
		ProRightDO proRight = proRightDao.getEffectiveProRightByHouse(coalition);
		String lastStrategy = proRight.getChargeSelect();
		proRight.setChargeSelect(vo.getCoalitionStrategy());



		if(!BlankUtil.isBlank(vo.getBankAccount()) && checkBankAccount(vo.getBankAccount())){
			//管理房银行帐户
			BankAccountDomain bankAccount = bankAccountService.currentBankAccount(coalition,false);

			if (BlankUtil.isBlank(bankAccount)) {
				//增加银行帐号
				bankAccount = new BankAccountDomain();
				BankDomain bank = feeBankDao.findById(vo.getBankAccount().getBankId());
				//从给定的产权房帐号中复制过来
				BeanUtil.convertVoAsDo(vo.getBankAccount(),bankAccount);
				bankAccount.setKeyword(null);
				bankAccount.setSysInfo(info);
				bankAccount.setHouse(coalition);
				bankAccount.setBank(bank);
				bankAccount.setIsActive(SysrefcodeDO.CONSTANTS_DIGITAL_ONE);
				bankAccount.setProRight(proRight);
				bankAccountDao.saveObject(bankAccount);
			} else {
				//修改银行帐号
				bankAccountService.activationBankAccount(bankAccount);
				//按这个产权房的帐户修改
				BankAccountVO srcBankAccount = vo.getBankAccount();
				BankDomain bank = feeBankDao.findById(srcBankAccount.getBankId());
				bankAccount.setBank(bank);
				bankAccount.setAccOwner(srcBankAccount.getAccOwner());
				bankAccount.setAccNumber(srcBankAccount.getAccNumber());
				bankAccount.setContactNumber(srcBankAccount.getContactNumber());

			}
		}


		//从分开记帐修改为合并记帐
		if(SysrefcodeDO.CONSTANTS_DIGITAL_ZERO.equals(vo.getCoalitionStrategy()) &&
				SysrefcodeDO.CONSTANTS_DIGITAL_ONE.equals(lastStrategy)) {

			//不存在管理房帐户
			ProRightDO pro = proRightDao.getEffectiveProRightByHouse(coalition);
			AccountDomain account = accountDao.getAccountBy(pro.getProRightId(), coalition.getKeyword(),false);
			if(BlankUtil.isBlank(account)){
				accountService.addAccount(coalition,proRight,info);
			}else{
				accountService.activeAccount(account);
			}
			//禁用产权房帐户和银行帐号并把记帐策略改为合并
			for (HouseDomain h: coalition.getHouses()) {
				AccountDomain acc = accountService.currentAccount(h);
				if(transactionService.checkAccountHasHangsTransaction(acc.getAccountId())){
					throw new BusinessException("house:house_coalitionhouse_hashangs_edit_exception",BusinessException.ERROR);
				}
				accountService.disableAccount(acc);
				BankAccountDomain localBankAccount = bankAccountService.currentBankAccount(h,true);
				if(!BlankUtil.isBlank(localBankAccount))
					bankAccountService.disableBankAccount(localBankAccount);
				ProRightDO proRightFlat = proRightDao.getEffectiveProRightByHouse(h);
				proRightFlat.setChargeSelect(SysrefcodeDO.CONSTANTS_DIGITAL_ZERO);
			}
		}

		//从合并记帐修改为分开记帐
		if(SysrefcodeDO.CONSTANTS_DIGITAL_ONE.equals(vo.getCoalitionStrategy()) &&
				SysrefcodeDO.CONSTANTS_DIGITAL_ZERO.equals(lastStrategy)){

			AccountDomain account = accountService.currentAccount(coalition);
			if(transactionService.checkAccountHasHangsTransaction(account.getAccountId())){
				throw new BusinessException("house:house_coalitionhouse_hashangs_edit_exception",BusinessException.ERROR);
			}
			if(!BlankUtil.isBlank(account))
				accountService.disableAccount(account);
			BankAccountDomain bankaccount = bankAccountService.currentBankAccount(coalition,true);
			if(!BlankUtil.isBlank(bankaccount))
				bankAccountService.disableBankAccount(bankaccount);
			//启用产权房帐户和银行帐号并把记帐策略改为分开
			for (HouseDomain h: coalition.getHouses()) {
					ProRightDO right = this.proRightDao.getEffectiveProRightByHouse(h);
					AccountDomain acc =  accountDao.getAccountBy(right.getProRightId(), h.getKeyword(), false);
					accountService.activeAccount(acc);
					BankAccountDomain localBankAccount = bankAccountService.currentBankAccount(h,false);
					if(!BlankUtil.isBlank(localBankAccount))
						bankAccountService.activationBankAccount(localBankAccount);
					ProRightDO proRightFlat = proRightDao.getEffectiveProRightByHouse(h);
					proRightFlat.setChargeSelect(SysrefcodeDO.CONSTANTS_DIGITAL_ONE);
			}
		}

	}

	/***
	 * 功能描述:  去掉房间列表中的重复的业主<br>
	 * @param list
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2008-9-5  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private Set<ClientRHouseDO> excludeExistClientRHouseDO(List<ClientRHouseDO> list)
	{
		Set<ClientRHouseDO> set = new HashSet<ClientRHouseDO>();
		Set<Long> set1 = new HashSet<Long>();
		for(ClientRHouseDO clientRhouse: list)
		{
			boolean result = set1.add(clientRhouse.getClient().getParticipantRoleId());
			if(result)
			{
				set.add(clientRhouse);
			}
		}
		return set;
	}


	/***
	 * 功能描述:  验证两个管理房不能共用相同的产权房<br>
	 * @param coalition
	 * Create author:yandawei <br>
	 * Create on:2008-8-27  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private void checkValidity(CoalitionHouseDomain coalition) {
		if(coalitionHouseDao.checkHousesDuplicate(coalition)){
			throw new BusinessException("house:house_coalition_duplicate",BusinessException.FAILURE);
		}
		//验证房子是否处于退伙中
		for(HouseDomain house : coalition.getHouses()){
			if(!BlankUtil.isBlank(proRightChangeService.checkTheHouseNumber(house.getKeyword()))){
				throw new BusinessException("house:house_in_goout,"+house.getHouseNumber(),BusinessException.FAILURE);
			}
		}

	}
	/***
	 * 功能描述: 检验合并房数目是否大于2 <br>
	 * @param houseStr
	 * Create author:yandawei <br>
	 * Create on:2008-10-29  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private void checkValidity(String houseStr)
	{
		String[] houseIds = houseStr.split(",");
		if(houseIds.length<2)
			throw new BusinessException("house:house_coalition_housesmorethantwo",BusinessException.FAILURE);

	}

	/***
	 * 功能描述:  检验管理房号是否以存在<br>
	 * @param houseNumber
	 * @param coalitionHouseId
	 * Create author:yandawei <br>
	 * Create on:2008-9-9  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private void checkCoalitionHouseNumber(String houseNumber , Long coalitionHouseId)
	{
		if(BlankUtil.isBlank(coalitionHouseId)){
			if(houseService.checkIsOnlyHouseNoInHouseAndCoalitionHouse(houseNumber)){
				throw new BusinessException("house:house_coalition_housenumberexist",BusinessException.FAILURE);
			}
		} else {
			if(houseService.checkIsOnlyHouseNoInHouseAndCoalitionHouse(houseNumber,coalitionHouseId)){
				throw new BusinessException("house:house_coalition_housenumberexist",BusinessException.FAILURE);
			}
		}
	}

	/**
	 * 功能描述:  验证银行账号必填项验证,通过返回true,否则返回false<br>
	 * @param bankAccount
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2008-8-26  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private boolean checkBankAccount(BankAccountVO bankAccount)
	{
		if(BlankUtil.isBlank(bankAccount.getAccNumber()) ||
				BlankUtil.isBlank(bankAccount.getBankId()) ||
				BlankUtil.isBlank(bankAccount.getAccOwner()) ){
			return false;
		}
		else
			return true;
	}



	/***
	 * 功能描述:  从houseStr中返回持久化的HouseDomain集合<br>
	 * @param houseStr
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2008-10-29  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private Set<HouseDomain>  getHouses(String houseStr) {
		Set<HouseDomain> retValue = new HashSet<HouseDomain>();
		String[] houseIds = houseStr.split(",");
		for(String houseId: houseIds) {
			HouseDomain house = houseDao.findById(Long.valueOf(houseId));
			//判断产权是否存在
			if(BlankUtil.isBlank(proRightDao.getEffectiveProRightByHouse(house)))
			{
				throw new BusinessException("house:house_proright_not_exist",BusinessException.FAILURE);
			}
			retValue.add(house);
		}
		return retValue;
	}

	public CoalitionHouseVO findCoalitionHouseById(Long id) {
		CoalitionHouseDomain coalitionHouse = coalitionHouseDao.findById(id);
		if(BlankUtil.isBlank(coalitionHouse))
			return null;
		else
			return coalitionToVO(coalitionHouse);
	}

	/***
	 * 功能描述: 将查询出来的CoalitionHouseDomain转换成CoalitionVO <br>
	 * @param coalition
	 * @return
	 * Create author:yandawei <br>
	 * Create on:2008-10-29  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	private CoalitionHouseVO coalitionToVO(CoalitionHouseDomain coalition) {
		CoalitionHouseVO retValue= new CoalitionHouseVO();
		retValue.setCoalitionHouseNumber(coalition.getHouseNumber());
		retValue.setCoalitionType(coalition.getCoalitionType().getId());
		retValue.setValidity(coalition.getValidity());
		retValue.setCoalitionId(coalition.getKeyword());

		ProRightDO proRightFlat = proRightDao.getEffectiveProRightByHouse(coalition);
		retValue.setCoalitionStrategy(proRightFlat.getChargeSelect());

		if(SysrefcodeDO.CONSTANTS_DIGITAL_ZERO.equals(proRightFlat.getChargeSelect())){
			BankAccountDomain bankAccount = bankAccountService.currentBankAccount(coalition,true);
			if(!BlankUtil.isBlank(bankAccount)){
				BankAccountVO bankAccountVO = new BankAccountVO();
				BeanUtil.convertVoAsDo(bankAccount,bankAccountVO);
				bankAccountVO.setBankId(bankAccount.getBank().getKeyword());
				retValue.setBankAccount(bankAccountVO);
			}
		}

		for(HouseDomain h:coalition.getHouses()) {
			retValue.getHouseMap().put(h.getKeyword(), h.getHouseNumber());
		}
		return retValue;
	}



	/* (non-Javadoc)
	 * @see com.ce.pms.house.service.ICoalitionHouseService#getCoalitionHouse(java.lang.String)
	 */
	public List<CoalitionHouseVO> getCoalitionHouse(String relationType) {
		// TODO Auto-generated method stub
		return null;
	}

	/**
	 *
	 * 功能描述: 根据管理房号查询管理房实体，如果不存在返回空值。
	 * 只查询有效的信息，
	 *
	 * @author 付湘辉
	 * Created on:2008-7-1
	 *
	 * 修改原因：
	 * @param houseNumber　管理房号
	 * @return CoalitionHouseDomain 返回结果
	 */
	public CoalitionHouseDomain getCoalitionHouseByHouseNumber(String houseNumber){
		super.checkParameterIsNull(houseNumber,"common:parameters_null_exception, ");
		return this.coalitionHouseDao.getCoalitionHouseByHouseNumber(houseNumber);
	}



	/* (non-Javadoc)
	 * @see com.ce.pms.house.service.ICoalitionHouseService#getCoalitionRelation(java.lang.String)
	 */
	public List<CoalitionHouseVO> getCoalitionRelation(String relationType) {
		// TODO Auto-generated method stub
		return null;
	}
	public void setCoalitionHouseDao(ICoalitionHouseDao coalitionHouseDao) {
		this.coalitionHouseDao = coalitionHouseDao;
	}
	public void setHouseDao(IHouseDao houseDao) {
		this.houseDao = houseDao;
	}

	public void setAccountService(IAccountService accountService) {
		this.accountService = accountService;
	}

	public void setBankAccountService(IBankAccountService bankAccountService) {
		this.bankAccountService = bankAccountService;
	}

	public void setBankAccountDao(IBankAccountDao bankAccountDao) {
		this.bankAccountDao = bankAccountDao;
	}

	public void setClientRHouseDao(IClientRHouseDao clientRHouseDao) {
		this.clientRHouseDao = clientRHouseDao;
	}

	public void setProRightDao(IProRightDao proRightDao) {
		this.proRightDao = proRightDao;
	}

	public void setFeeBankDao(IFeeBankDao feeBankDao) {
		this.feeBankDao = feeBankDao;
	}


	public List<HouseVO> getPropertyHouseByCoalitionId(Long id) {
		CoalitionHouseDomain coalitionHouseDomain = coalitionHouseDao.findById(id);
		List<HouseVO> list = new ArrayList<HouseVO>();
		for(HouseDomain house : coalitionHouseDomain.getHouses())
		{
			PeriodDomain period =   periodService.findPeriodByHouseId(house.getKeyword());
			if(BlankUtil.isBlank(period)){
				throw new BusinessException("house:house_period_not_exist",BusinessException.FAILURE);
			}
			HouseVO h = new HouseVO();
			h.setHouseNumber(house.getHouseNumber());
			h.setKeyword(house.getKeyword());
			h.setPeriodId(period.getKeyword());
			list.add(h);
		}
		return list;
	}

	public void setAccountDao(IAccountDao accountDao) {
		this.accountDao = accountDao;
	}




}
